import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
       ExecutorService service= Executors.newFixedThreadPool(4);
        for (int i = 0; i < 100; i++) {
            int id=i;
            service.submit(()->{
                Thread current=Thread.currentThread();
                System.out.println(+id+""+current.getName());
            });
        }
        // 不要立刻就终止，要等线程池里的线程把任务执行完
        Thread.sleep(1000);
        //  终止全部线程池线程
        service.shutdown();
        System.out.println("程序退出");
    }
}
